#-*-coding: UTF-8 -*-
import os

# redis 主机
REDIS_HOST = "192.168.64.2"  # 安装在centos时需要 /etc/redis/6379.conf: bind 192.168.10.1
REDIS_PORT = "6379"

# mysql连接参数
MYSQL = {
    'DB': 'hmovie',
    'USR': 'root',
    'PWD': '1234',
    'HOST': '192.168.64.2',
    'PORT': '3306',
    'CHARSET': 'charset=utf8',
    'DB_MODULE': 'mysqlconnector'
    # 'DB_MODULE': 'pymysql'     # 此模块在py3 报1366 更换为 mysql-connector
}

# 上传文件目录
UPLOAD_DIR = "app/static/uploads/"

# 超管账号
SUPPER_USER = {'name': 'admin', 'pwd': '123456'}
# sqlalchemy_mysql 连接语句
LINK = "mysql+%s://%s:%s@%s:%s/%s?%s" \
    % (MYSQL['DB_MODULE'], MYSQL['USR'], MYSQL['PWD'], MYSQL['HOST'], MYSQL['PORT'], MYSQL['DB'], MYSQL['CHARSET'])


class BaseConfig(object):
    '''
    基类
    '''
    # db & sqlachme
    DB = 'movie'  # 数据库需要预先在mysql建立
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_DATABASE_URI = LINK
    SQLALCHEMY_POOL_SIZE = 5
    SQLALCHEMY_POOL_TIMEOUT = 30
    SQLALCHEMY_POOL_RECYCLE = -1
    #
    SECRET_KEY = '9b4f9e04d5fe461a957bac1d47c694a0'  # uuid.uuid4().hex
    UP_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                          UPLOAD_DIR)
    DEBUG = False
    TOKEN_EXPIRATION = 30 * 24 * 3600

    # redis url
    REDIS_URL = "redis://%s:%s/0" % (REDIS_HOST, REDIS_PORT)


class ProductionConfig(BaseConfig):
    '''
    上线
    '''
    DEBUG = False


class DevelopmentConfig(BaseConfig):
    '''
    开发
    '''
    DEBUG = True
    TOKEN_EXPIRATION = 500


class CreateDbConfig(BaseConfig):
    '''
    用于创建数据
    '''
    DEBUG = True
    SQLALCHEMY_TRACK_MODIFICATIONS = True
